package com.mysiteforme.admin.util;

import com.alibaba.fastjson.JSONObject;
import com.mysiteforme.admin.entity.ElectricityCompany;
import com.mysiteforme.admin.entity.publish.ElectricityOrder;
import com.mysiteforme.admin.entity.publish.ElectricitySupply;

import java.text.SimpleDateFormat;

public class MessageConstants {

    /**
     * 用户审核
     *
     * @param first
     * @param
     * @return
     */
    public static final String messageId_pass = "z6m0arK4TXRphcz5JwFApqxJcFT-vE-Dr58ckpLKdiA";//模板ID
    public static final String messageId_fail = "Utkw6g7F2pWq2ygQo1LGblKkm22UTqVHbuumKRyrGQY";//模板ID


    public static JSONObject sendUser(ElectricityCompany company) {
        JSONObject json = new JSONObject();
        SimpleDateFormat formatter  = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

         //审核时间
        SendMessagesTemplete sendMessagesTemplete1 = new SendMessagesTemplete( formatter.format(company.getUpdateDate()), Constants.MEESSAGE_PUSH_COLOUR);
        json.put("keyword1", sendMessagesTemplete1);

        if(company.getIsCheck().equals("1")) {
            SendMessagesTemplete sendMessagesTemplete = new SendMessagesTemplete(
                    "您的信息已通过审核", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("first", sendMessagesTemplete);
            //企业名称
            SendMessagesTemplete sendMessagesTemplete2 = new SendMessagesTemplete(company.getCompanyName(), Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword2", sendMessagesTemplete2);
        } else if (company.getIsCheck().equals("2")) {
            SendMessagesTemplete sendMessagesTemplete = new SendMessagesTemplete(
                    "您的信息未通过审核", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("first", sendMessagesTemplete);
            //审核内容
            SendMessagesTemplete sendMessagesTemplete2 = new SendMessagesTemplete("企业信息审核", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword2", sendMessagesTemplete2);
            //失败原因
            SendMessagesTemplete sendMessagesTemplete3 = new SendMessagesTemplete(company.getRefuseMsg(), Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword3", sendMessagesTemplete3);
        }

        SendMessagesTemplete templete4 = new SendMessagesTemplete("如有疑问请联系管理员！", Constants.MEESSAGE_PUSH_COLOUR);
        json.put("remark", templete4);

        return json;
    }

    /**
     * 供需发布审核
     *
     * @param first
     * @param
     * @return
     */
    public static final String messageId_supply = "M-Hj5f4cg9Rpw4v5MD33OXAZvPCntA098-AaJW81608";//通过模板ID
    public static final String messageId_refuse = "RUuro7j02S1IUWrpfL05bva4nxIMUGXx85mHPg8xRl0";//驳回模板ID
    public static final String check_pass = "审核通过！";
    public static final String check_remark = "点击详情可以查看信息！";

    public static JSONObject sendSupply(ElectricitySupply supply) {
        JSONObject json = new JSONObject();
        SimpleDateFormat formatter  = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if(supply.getAuditingStatu().equals("1")){
            SendMessagesTemplete sendMessagesTemplete = new SendMessagesTemplete(
                    "审核通过", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("first", sendMessagesTemplete);
            //信息标题
            SendMessagesTemplete sendMessagesTemplete1 = new SendMessagesTemplete("供需发布审核", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword1", sendMessagesTemplete1);
            //发布时间
            SendMessagesTemplete sendMessagesTemplete2 = new SendMessagesTemplete(formatter.format(supply.getPublishTime()), Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword2", sendMessagesTemplete2);
            //进展状态
            SendMessagesTemplete sendMessagesTemplete3 = new SendMessagesTemplete("审核通过", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword3", sendMessagesTemplete3);
            SendMessagesTemplete templete4 = new SendMessagesTemplete("您可以发布消息咯", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("remark", templete4);
        }else if(supply.getAuditingStatu().equals("2")){
            SendMessagesTemplete sendMessagesTemplete = new SendMessagesTemplete(
                    "审核驳回", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("first", sendMessagesTemplete);
            //审核时间
            SendMessagesTemplete sendMessagesTemplete1 = new SendMessagesTemplete(formatter.format(supply.getUpdateDate()), Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword1", sendMessagesTemplete1);
            //审核内容
            SendMessagesTemplete sendMessagesTemplete2 = new SendMessagesTemplete("供需发布审核", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword2", sendMessagesTemplete2);
            //失败原因
            SendMessagesTemplete sendMessagesTemplete3 = new SendMessagesTemplete(null, Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword3", sendMessagesTemplete3);
            SendMessagesTemplete templete4 = new SendMessagesTemplete("如有疑问请联系管理员", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("remark", templete4);
        }
        return json;
    }

    /**
     * 买方/卖方
     *
     * @param first
     * @param
     * @return
     */
    public static final String message_id = "uuv5uLQd-cRTvBg3Z-Zcxv5nXuqpjIMBA7N62Nq2h4o";//模板ID
    public static final String get_url = "http://cs.taodiandating.cn/view/#/me/myOrder?type=wechat";

    public static JSONObject sendMessage(ElectricityOrder order,String user_type) {
        JSONObject json = new JSONObject();
        if(user_type.equals("1")) {
            SendMessagesTemplete sendMessagesTemplete = new SendMessagesTemplete(order.getSellCompany() +
                    ",您好!您在【" + order.getBuyCompany() + "】的订单已经处理", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("first", sendMessagesTemplete);
        }else if(user_type.equals("2")) {
            SendMessagesTemplete sendMessagesTemplete = new SendMessagesTemplete(
                    "您好!【" + order.getSellCompany() + "】的订单已经处理", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("first", sendMessagesTemplete);
        }
        if(order.getOrderStatu().equals("2")) {
            //订单状态
            SendMessagesTemplete sendMessagesTemplete2 = new SendMessagesTemplete(
                    "已上报电力交易平台", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword2", sendMessagesTemplete2);
        }else if(order.getOrderStatu().equals("3")) {
            //订单状态
            SendMessagesTemplete sendMessagesTemplete2 = new SendMessagesTemplete(
                    "交易已完成", Constants.MEESSAGE_PUSH_COLOUR);
            json.put("keyword2", sendMessagesTemplete2);
        }

        //订单编号
        SendMessagesTemplete sendMessagesTemplete1 = new SendMessagesTemplete(
                order.getTradeNo(), Constants.MEESSAGE_PUSH_COLOUR);
        json.put("keyword1", sendMessagesTemplete1);

        SendMessagesTemplete templete3 = new SendMessagesTemplete("点击“详情”,查看完整订单信息", Constants.MEESSAGE_PUSH_COLOUR);
        json.put("remark", templete3);

        return json;
    }


}
